package com.itheima.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import com.itheima.reggie.entity.SetmealDish;
import com.itheima.reggie.mapper.SetmealDishMappr;
import com.itheima.reggie.service.SetMealDishService;
import com.itheima.reggie.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
@Transactional
public class SetmealDishServcieImpl implements SetMealDishService {
    @Autowired
    private SetmealDishMappr setmealDishMappr;
//    @Override
//    public int insert(SetmealDish setmealDish) {
//        return setmealDishMappr.insert(setmealDish);
//    }
//
//    @Override
//    public int delete(Long id) {
//        LambdaQueryWrapper<SetmealDish> lqw=new LambdaQueryWrapper<>();
//        lqw.eq(SetmealDish::getSetmealId,id);
//        return setmealDishMappr.delete(lqw);
//    }

    /**
     * 添加套餐的数据
     *
     * @param setmealDish
     * @return
     */
    @Override
    public int add(SetmealDish setmealDish) {
        return setmealDishMappr.insert(setmealDish);
    }

    @Override
    public int deleteBySetmealId(Long id) {
        LambdaQueryWrapper<SetmealDish> lqw=new LambdaQueryWrapper<>();
        lqw.eq(SetmealDish::getSetmealId,id);
        return setmealDishMappr.delete(lqw);
    }

    @Override
    public List<SetmealDish> findsetmealid(Long setmealid) {
        LambdaQueryWrapper<SetmealDish> qw=new LambdaQueryWrapper<>();
        qw.eq(SetmealDish::getSetmealId,setmealid);
        return setmealDishMappr.selectList(qw);
    }
}
